#!/bin/sh
SEARCH_PID=`ps uax | egrep -i "(searchd)" |grep "sphinx" | awk '{print $2}'`
if [[ "$SEARCH_PID" != "" ]]; then
	#/usr/local/csft/bin/indexer --config /usr/local/csft/etc/sphinx.conf --merge shop_info_index shop_info_stemmed --merge-dst-range deleted 0 0 --rotate && \
	/usr/local/csft/bin/indexer --rotate --config /usr/local/csft/etc/sphinx.conf shop_info_stemmed && \
	#/usr/local/csft/bin/indexer --config /usr/local/csft/etc/sphinx.conf --merge list_index list_stemmed --merge-dst-range deleted 0 0 --rotate && \
	/usr/local/csft/bin/indexer --rotate --config /usr/local/csft/etc/sphinx.conf list_stemmed && \
	#/usr/local/csft/bin/indexer --config /usr/local/csft/etc/sphinx.conf --merge review_index review_stemmed --merge-dst-range deleted 0 0 --rotate && \
	/usr/local/csft/bin/indexer --rotate --config /usr/local/csft/etc/sphinx.conf review_stemmed && \
	#/usr/local/csft/bin/indexer --config /usr/local/csft/etc/sphinx.conf --merge product_info_index product_info_stemmed --merge-dst-range deleted 0 0 --rotate && \
	/usr/local/csft/bin/indexer --rotate --config /usr/local/csft/etc/sphinx.conf product_info_stemmed && \
	#/usr/local/csft/bin/indexer --config /usr/local/csft/etc/sphinx.conf --merge user_info_index user_info_stemmed --merge-dst-range deleted 0 0 --rotate && \
	/usr/local/csft/bin/indexer --rotate --config /usr/local/csft/etc/sphinx.conf user_info_stemmed
else
	echo "searchd is not started, maybe whole indexing is running,  skipping..."
fi
